package cn.zhoabab.study.seata.storage.controller;

import lombok.extern.slf4j.Slf4j;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.zhoabab.study.seata.storage.service.StorageService;

@Slf4j
@RestController
@RequestMapping("/storage")
public class StorageController {
    @Autowired
    private StorageService storageService;

    @PostMapping("/reduce")
    public ResponseEntity reduceStock(@RequestParam("code")String code, @RequestParam("num") Long num) {
        log.info(">>>> request params: code={}, nums={} <<<<",code,num);
        Map<String,Object> result = storageService.reduceStock(code, num);
        return ResponseEntity.ok(result);
    }
}
